Ext.require([
    'Ext.form.field.ComboBox',
    'Ext.form.FieldSet',
    'Ext.tip.QuickTipManager',
    'Ext.toolbar.Paging',
    'Ext.grid.*',
    'Ext.data.*',
    'Ext.util.*',
    'Ext.state.*'
]);
//房源panal
var gridStore = null;
var gridStore2 = null;
var gridStore3 = null;
var gridStore4 = null;
var houseTypeIdStore = null;
var premisesIdStore = null;
var roomIdStore = null;
var relationshipStore = null;
var rqTheirMotivesStore = null;
var rqFocusIdStore = null;
var rqDemandFloorStore = null;
var rqServicesIdStore = null;
var rqLifeSupportStore = null;
var rqCourtyardFunctionStore = null;
var familyJieStore = null;
var ftContactWayStore = null;
var peFrameBrandIdStore = null;
var peAcademicQualificationsStore = null;
var peActivityTypeStore = null;
var congshihangyeStore = null;
var companyXingzhiStore = null;
var riChangXinXiStore = null;
var reCurrentlyPropertyStore = null;
var reCurrentlyHouseStore = null;
var reCurrentlyStructureStore = null;
var coWeekendInformationStore = null;
var peDocumentTypeStore = null;

var objData = null;
//工作城市
var peWorkaroundCityIdStore = null;
//工作区域
var peWorkaroundAreaIdStore = null;
//城市
var peResidenceCityIdStore = null;
//区域
var peResidenceAreaIdStore = null;
var documentTypeStore = null;

function storeMethed(result){
    return new Ext.data.Store({
        autoDestroy: true,
        fields :["des","no"],
        data : result
    });
}
var AJCouple = "peContactAddress,rqTheirMotives,rqDemandArea,rqServicesId,rqLifeSupport,rqPaymentMethod,peResidenceProvinceId,peResidenceCityId,peResidenceAreaId,rqFocusId,peDocumentType,peDocumentNumber,peBirth,peDomicilePlace,peWorkaroundProvinceId,peWorkaroundCityId,peWorkaroundAreaId,richangxinxi,peHobbyId,peActivityType";
var ACouple = "rqTheirMotives,rqDemandArea,rqServicesId,rqLifeSupport,rqPaymentMethod,peResidenceProvinceId,peResidenceCityId,peResidenceAreaId,rqFocusId,peWorkaroundProvinceId,peWorkaroundCityId,peWorkaroundAreaId";
var BCouple = "";
var CCouple = "";
var DCouple = "";
var ALLCouple = [];

function userOption(type){
    if(ALLCouple.length!=0){
        for(var i=0;i<ALLCouple.length;i++){
            var allcObj = Ext.getCmp(ALLCouple[i]);
            if(ALLCouple[i]=="peResidenceCityId" || ALLCouple[i]=="peResidenceAreaId" || ALLCouple[i]=="peWorkaroundCityId" || ALLCouple[i]=="peWorkaroundAreaId" ){

            }else{
                allcObj.setFieldLabel(allcObj.fieldLabel.replace("*",""));
            }
            allcObj.allowBlank=true;
            allcObj.blankText='';
        }
    }
    //清楚掉上一次的，保存这一次的.
    ALLCouple = new Array();
    //AJAX加载数据,不让页面加载JS时间过长，导致页面卡死
    var text=[];
    if(type=="1"){
        text=AJCouple.split(",");
    }else if(type=="2"){
        text=ACouple.split(",");
    }else if(type=="3"){
        text=BCouple.split(",");
    }else if(type=="4"){
        text=CCouple.split(",");
    }else if(type=="5"){
        text=DCouple.split(",");
    }
    for(var i=0;i<text.length;i++){
        var ajObj = Ext.getCmp(text[i]);
        if(null!=ajObj){
            if(text[i]=="peResidenceCityId" || text[i]=="peResidenceAreaId" || text[i]=="peWorkaroundCityId" || text[i]=="peWorkaroundAreaId" ){

            }else{

                ajObj.setFieldLabel("<font style='color:#e90000;'>*</font>"+ajObj.fieldLabel);
            }
            ajObj.allowBlank=false;
            ajObj.blankText='不能为空';
            ALLCouple.push(text[i]);
        }

    }
}

Ext.onReady(function() {
    peWorkaroundCityIdStore = new Ext.data.Store({
        singleton:true,
        autoDestroy:true,
        fields: ["areaName", "id"],
        proxy:{
            type:'ajax',
            url:contextPath+'/customer/customer/cityList',
            reader:{
                type: 'json',
                root: 'root'  //数据
            }
        }
    });
    peWorkaroundAreaIdStore = new Ext.data.Store({
        singleton:true,
        autoDestroy:true,
        fields: ["areaName", "id"],
        proxy:{
            type:'ajax',
            url:contextPath+'/customer/customer/areaList',
            reader:{
                type: 'json',
                root: 'root'  //数据
            }
        }
    });
    peResidenceCityIdStore = new Ext.data.Store({
        singleton:true,
        autoDestroy:true,
        fields: ["areaName", "id"],
        proxy:{
            type:'ajax',
            url:contextPath+'/customer/customer/cityList',
            reader:{
                type: 'json',
                root: 'root'  //数据
            }
        }
    });
    peResidenceAreaIdStore = new Ext.data.Store({
        singleton:true,
        autoDestroy:true,
        fields: ["areaName", "id"],
        proxy:{
            type:'ajax',
            url:contextPath+'/customer/customer/areaList',
            reader:{
                type: 'json',
                root: 'root'  //数据
            }
        }
    });
    houseTypeIdStore = new Ext.data.Store({
        fields: ["houseTypeName", "id"],
        proxy:{
            type:'ajax',
            url:contextPath+'/customer/customer/projectHouseTypeList',
            reader:{
                type: 'json',
                root: 'root'  //数据
            }
        }
    });
    premisesIdStore = new Ext.data.Store({
        fields: ["groupName", "id"],
        proxy:{
            type:'ajax',
            url:contextPath+'/customer/customer/projectPremisesList',
            reader:{
                type: 'json',
                root: 'root'  //数据
            }
        }
    });
    roomIdStore = new Ext.data.Store({
        fields: ["combinedName", "id"],
        proxy:{
            type:'ajax',
            url:contextPath+'/customer/customer/projectRoomList',
            reader:{
                type: 'json',
                root: 'root'  //数据
            }
        }
    });
    gridStore = Ext.create('Ext.data.Store', {
        fields: ["id","memberName","documentType", "documentNumber"
            , "birthday","marryday", "mobile", "relationship", "peMobile"],
        //是否在服务端排序 （true的话，在客户端就不能排序）
        remoteSort: false,
        proxy: {
            type: 'ajax',
            url: contextPath+'/customer/familyMember/findList',
            //url: contextPath+'/customer/customer/familyMemberList',
            actionMethods: { read: 'POST' },
            reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
                type: 'json', //返回数据类型为json格式
                root: 'obj',  //数据
                totalProperty: 'total' //数据总条数
            }
        },
        autoLoad: false  //即时加载数据
    });

    gridStore.on("beforeload",function(){
        Ext.apply(gridStore.proxy.extraParams,{customerId:customerId,memberType:'1'});
    });
    gridStore3 = Ext.create('Ext.data.Store', {
        fields: ["premisesId","groupName"],
        pageSize: 10,  //页容量5条数据
        //是否在服务端排序 （true的话，在客户端就不能排序）
        remoteSort: false,
        proxy: {
            type: 'ajax',
            url: contextPath+'/customer/customer/premisesList',
            actionMethods: { read: 'POST' },
            reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
                type: 'json', //返回数据类型为json格式
                root: 'rows',  //数据
                totalProperty: 'total' //数据总条数
            }
        },
        autoLoad: true  //即时加载数据
    });

    gridStore3.on("beforeload",function(){
        Ext.apply(gridStore3.proxy.extraParams,{customerId:customerId});
    });
    gridStore2 = Ext.create('Ext.data.Store', {
        fields: ["houseTypeId","houseTypeName"],
        pageSize: 10,  //页容量5条数据
        //是否在服务端排序 （true的话，在客户端就不能排序）
        remoteSort: false,
        proxy: {
            type: 'ajax',
            url: contextPath+'/customer/customer/houseTypeList',
            actionMethods: { read: 'POST' },
            reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
                type: 'json', //返回数据类型为json格式
                root: 'rows',  //数据
                totalProperty: 'total' //数据总条数
            }
        },
        autoLoad: true  //即时加载数据
    });

    gridStore2.on("beforeload",function(){
        Ext.apply(gridStore2.proxy.extraParams,{customerId:customerId});
    });
    gridStore4 = Ext.create('Ext.data.Store', {
        //,"combinedName"
        fields: ["roomId","combinedName"],
        pageSize: 10,  //页容量5条数据
        //是否在服务端排序 （true的话，在客户端就不能排序）
        remoteSort: false,
        proxy: {
            type: 'ajax',
            url: contextPath+'/customer/customer/roomList',
            actionMethods: { read: 'POST' },
            reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
                type: 'json', //返回数据类型为json格式
                root: 'rows',  //数据
                totalProperty: 'total' //数据总条数
            }
        },
        autoLoad: true  //即时加载数据
    });

    gridStore4.on("beforeload",function(){
        Ext.apply(gridStore4.proxy.extraParams,{customerId:customerId});
    });
});


Ext.define('customer.payDeposit.add.estatePanel',{
    extend : 'Ext.form.Panel',
    initComponent:function(){
        var cbstore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["projectName", "id"],
            proxy:{
                type:'ajax',
                url:contextPath+'/customer/follow/returnProjectName?resourcesCode=menu_0003_0001&resourcesName=resName_pro_list',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            },
            autoLoad:true
        });


        var sexStoreList = [
            {"value":"1","text":"男"},
            {"value":"2","text":"女"}
        ];
        var sexStore = Ext.data.Store({
            autoDestroy: true,
            fields :["value","text"],
            data : sexStoreList
        });

        informedWayStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });
        // informedWayStore.load({
        // 	callback: function(records, operation, success){
        // 		informedWayStore.filter("delFlag", 0);
        // 	}
        // });

        var recommendedCategoryStoreList = [{"value":"1","text":"分销/中介"},
            {"value":"2","text":"老客户(未成交客户)"},
            {"value":"3","text":"老业主"}];

        var recommendedCategoryStore = Ext.data.Store({
            autoDestroy: true,
            fields :["value","text"],
            data : recommendedCategoryStoreList
        });

        var intentionLevelStoreList = [
            {"value":"2","text":"A"},
            {"value":"3","text":"B"},
            {"value":"4","text":"C"},
            {"value":"5","text":"D"}
        ];
        var intentionLevelStore = Ext.data.Store({
            autoDestroy: true,
            fields :["value","text"],
            data : intentionLevelStoreList
        });

        var me=this;
        var row_1={
            fieldDefaults: {
                labelAlign: 'top',
                msgTarget: 'side'
            },
            defaults: {
                border: false,
                xtype: 'panel',
                flex: 1,
                layout: 'anchor'
            },
            xtype: "container",
            layout: "hbox",
            items:[{
                minWidth: 200,
                xtype:'displayfield',
                fieldLabel:'经纪人',
                name:'userName'
            },{
                minWidth: 200,
                xtype:'displayfield',
                fieldLabel:'创建人',
                name:'createName'
            }]

        };
        var row_2={
            id:"isPaydepositTrue",
            fieldDefaults: {
                labelAlign: 'top',
                msgTarget: 'side'
            },
            defaults: {
                border: false,
                xtype: 'panel',
                flex: 1,
                layout: 'anchor'
            },
            border: false,
            layout: 'hbox',items: [{
                items: [{
                    xtype:'combobox',
                    id:'cbstore',
                    store: cbstore,
                    displayField: "projectName",
                    valueField: "id",
                    fieldLabel:'<font style="color:#e90000;">*</font>项目名称',
                    width:300,
                    queryMode:'local',
                    typeAhead: true,
                    name:'projectId',
                    listeners:{
                        'change':function(value){
                            houseTypeIdStore.load({
                                params:{
                                    'projectId':value.lastValue
                                }
                            });
                            premisesIdStore.load({
                                params:{
                                    'projectId':value.lastValue
                                }
                            });
                            roomIdStore.load({
                                params:{
                                    'projectId':value.lastValue
                                }
                            });
                            var projectId = value.lastValue;
                            if(projectId != ""){
                                //获知途径
                                Ext.getCmp('informedWay').setValue("");
                                informedWayStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'informedWay'
                                    },
                                    callback: function(records, options, success){
                                        informedWayStore.filter("delFlag", 0);
                                        projectReloadStore("informedWay", informedWayStore);
                                    }
                                });
                                //置业动机
                                // Ext.getCmp('rqTheirMotives').setValue("");
                                rqTheirMotivesStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'theirMotives'
                                    },
                                    callback: function(records, options, success){
                                        rqTheirMotivesStore.filter("delFlag", 0);
                                        projectReloadStore("rqTheirMotives", rqTheirMotivesStore);
                                    }
                                });
                                //关注重点
                                Ext.getCmp('rqFocusId').setValue("");
                                rqFocusIdStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'focus'
                                    },
                                    callback: function(records, options, success){
                                        rqFocusIdStore.filter("delFlag", 0);
                                        comoboxReset(value, rqFocusIdStore, 'rqFocusId');
                                    }
                                });
                                //需求楼层
                                // Ext.getCmp('rqDemandFloor').setValue("");
                                rqDemandFloorStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'floor'
                                    },
                                    callback: function(records, options, success){
                                        rqDemandFloorStore.filter("delFlag", 0);
                                        projectReloadStore("rqDemandFloor", rqDemandFloorStore);
                                    }
                                });
                                //生活服务
                                // Ext.getCmp('rqServicesId').setValue("");
                                rqServicesIdStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'lifeService'
                                    },
                                    callback: function(records, options, success){
                                        rqServicesIdStore.filter("delFlag", 0);
                                        comoboxReset(value, rqServicesIdStore, 'rqServicesId');
                                    }
                                });
                                //生活配套
                                // Ext.getCmp('rqLifeSupport').setValue("");
                                rqLifeSupportStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'lifeSupport'
                                    },
                                    callback: function(records, options, success){
                                        rqLifeSupportStore.filter("delFlag", 0);
                                        comoboxReset(value, rqLifeSupportStore, 'rqLifeSupport');
                                    }
                                });
                                //希望庭院具备功能
                                // Ext.getCmp('rqCourtyardFunction').setValue("");
                                rqCourtyardFunctionStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'courtyardFunction'
                                    },
                                    callback: function(records, options, success){
                                        rqCourtyardFunctionStore.filter("delFlag", 0);
                                        projectReloadStore("rqCourtyardFunction", rqCourtyardFunctionStore);
                                    }
                                });
                                //家庭结构
                                // Ext.getCmp('familyJie').setValue("");
                                familyJieStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'familyJie'
                                    },
                                    callback: function(records, options, success){
                                        familyJieStore.filter("delFlag", 0);
                                        projectReloadStore("familyJie", familyJieStore);
                                    }
                                });
                                //联系方式
                                // Ext.getCmp('ftContactWay').setValue("");
                                ftContactWayStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'contactWay'
                                    },
                                    callback: function(records, options, success){
                                        ftContactWayStore.filter("delFlag", 0);
                                        projectReloadStore("ftContactWay", ftContactWayStore);
                                    }
                                });
                                //车驾品牌
                                // Ext.getCmp('peFrameBrandId').setValue("");
                                peFrameBrandIdStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'frameBrand'
                                    },
                                    callback: function(records, options, success){
                                        peFrameBrandIdStore.filter("delFlag", 0);
                                        projectReloadStore("peFrameBrandId", peFrameBrandIdStore);
                                    }
                                });
                                //乐于参加的活动类型
                                // Ext.getCmp('peActivityType').setValue("");
                                peActivityTypeStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'activityType'
                                    },
                                    callback: function(records, options, success){
                                        peActivityTypeStore.filter("delFlag", 0);
                                        comoboxReset(value, peActivityTypeStore, 'peActivityType');
                                    }
                                });
                                //兴趣爱好
                                // Ext.getCmp('peHobbyId').setValue("");
                                peHobbyIdStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'hobby'
                                    },
                                    callback: function(records, options, success){
                                        peHobbyIdStore.filter("delFlag", 0);
                                        comoboxReset(value, peHobbyIdStore, 'peHobbyId');
                                    }
                                });
                                //学历
                                Ext.getCmp('peAcademicQualifications').setValue("");
                                peAcademicQualificationsStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'academicQualifications'
                                    },
                                    callback: function(records, options, success){
                                        peAcademicQualificationsStore.filter("delFlag", 0);
                                        projectReloadStore("peAcademicQualifications", peAcademicQualificationsStore);
                                    }
                                });
                                //从事行业
                                // Ext.getCmp('congshihangye').setValue("");
                                congshihangyeStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'congshihangye'
                                    },
                                    callback: function(records, options, success){
                                        congshihangyeStore.filter("delFlag", 0);
                                        projectReloadStore("congshihangye", congshihangyeStore);
                                    }
                                });
                                //公司性质
                                // Ext.getCmp('companyXingzhi').setValue("");
                                companyXingzhiStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'companyXingzhi'
                                    },
                                    callback: function(records, options, success){
                                        companyXingzhiStore.filter("delFlag", 0);
                                        projectReloadStore("companyXingzhi", companyXingzhiStore);
                                    }
                                });
                                //日常信息获取途径
                                // Ext.getCmp('richangxinxi').setValue("");
                                riChangXinXiStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'richangxinxi'
                                    },
                                    callback: function(records, options, success){
                                        riChangXinXiStore.filter("delFlag", 0);
                                        comoboxReset(value, riChangXinXiStore, 'richangxinxi');
                                    }
                                });
                                //目前居住物业类型
                                // Ext.getCmp('reCurrentlyProperty').setValue("");
                                reCurrentlyPropertyStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'currentlyProperty'
                                    },
                                    callback: function(records, options, success){
                                        reCurrentlyPropertyStore.filter("delFlag", 0);
                                        projectReloadStore("reCurrentlyProperty", reCurrentlyPropertyStore);
                                    }
                                });
                                //目前居住/办公房子属性
                                // Ext.getCmp('reCurrentlyHouse').setValue("");
                                reCurrentlyHouseStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'currentlyHouse'
                                    },
                                    callback: function(records, options, success){
                                        reCurrentlyHouseStore.filter("delFlag", 0);
                                        projectReloadStore("reCurrentlyHouse", reCurrentlyHouseStore);
                                    }
                                });
                                //目前居住户型结构
                                // Ext.getCmp('reCurrentlyStructure').setValue("");
                                reCurrentlyStructureStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'currentlyStructure'
                                    },
                                    callback: function(records, options, success){
                                        reCurrentlyStructureStore.filter("delFlag", 0);
                                        projectReloadStore("reCurrentlyStructure", reCurrentlyStructureStore);
                                    }
                                });
                                //联系方式
                                Ext.getCmp('coInformationDays').setValue("");
                                Ext.getCmp('coWeekendInformation').setValue("");
                                coWeekendInformationStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'contactInformation'
                                    },
                                    callback: function(records, options, success){
                                        coWeekendInformationStore.filter("delFlag", 0);
                                        projectReloadStore("coWeekendInformation", coWeekendInformationStore);
                                    }
                                });
                                //证件类型
                                // Ext.getCmp('peDocumentType').setValue("");
                                peDocumentTypeStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'documentType'
                                    },
                                    callback: function(records, options, success){
                                        peDocumentTypeStore.filter("delFlag", 0);
                                        projectReloadStore("peDocumentType", peDocumentTypeStore);
                                    }
                                });

                                //证件类型 （家庭成员列表）
                                documentTypeStore.load({
                                    params:{
                                        'projectId':projectId,
                                        'typeValue':'documentType'
                                    }
                                });
                            }
                        }
                    },
                    allowBlank:false,
                    blankText:'不能为空',
                    typeAhead:false,
                    editable:false

                },{
                    xtype:'textfield',
                    fieldLabel: '<font style="color:#e90000;">*</font>客户姓名',
                    width:300,
                    name: 'customerName',
                    allowBlank:false,
                    blankText:'不能为空',
                    id:'customerName'
                }, {
                    xtype:'combobox',
//			            style: 'position:absolute;left:15px;',
                    id:'customerSex',
                    store: sexStore,
                    displayField: "text",
                    valueField: "value",
                    fieldLabel:'<font style="color:#e90000;">*</font>性别',
                    width:300,
//			            queryMode:'local',
                    typeAhead: true,
                    name:'customerSex',
                    allowBlank:false,
                    blankText:'不能为空',
                    typeAhead:false,
                    editable:false
                }, {
                    xtype:'numberfield',
                    fieldLabel: '<font style="color:#e90000;">*</font>联系电话',
                    width:300,
                    name: 'customerPhone',
                    allowBlank:false,
                    blankText:'不能为空',
                    maxLength:11,
                    hideTrigger:true,
                    id:'customerPhone',
                    regex: /^1[3|4|5|6|7|8|9]\d{9}$/,
                    listeners:{
                        blur: function(value){
                            if(value.lastValue){
                                //在验证手机号码是否正确
                                Ext.Ajax.request({
                                    url: contextPath+'/common/mobile/verifyingMobile',
                                    params: {
                                        mobile: value.lastValue,
                                    },
                                    method: 'POST',
                                    async: false,
                                    success: function(response){
                                        var text = Ext.decode(response.responseText);
                                        if(text.result=="1"){
                                            if(text.flag != "1"){
                                                Ext.MessageBox.alert('提示', '请输入正确的手机号码');
                                            }
                                        }
                                    }
                                });
                                //判断手机号是否存在
                                var projectId = Ext.getCmp('cbstore').getValue();
                                var customerId = Ext.getCmp('customerId').getValue();
                                Ext.Ajax.request({
                                    url: contextPath+'/customer/customer/customerPhone',
                                    params: {
                                        phone: value.lastValue,
                                        projectId:projectId,
                                        id:customerId
                                    },
                                    method: 'POST',
                                    success: function(response){
                                        var text = Ext.decode(response.responseText);
                                        if(text.res=="1"){
                                            Ext.MessageBox.alert('提示', '该手机号码已存在!');
                                        }else if(text.res=="10000"){
                                            Ext.MessageBox.alert("系统提示","系统异常!");
                                        }
                                    }
                                });
                            }
                        }
                    }
                }, {
                    xtype:'textfield',
                    fieldLabel: '推荐人姓名',
                    width:300,
                    name: 'recommendedName',
                    id: 'recommendedName',
                    hidden:true
                }, {
                    xtype:'textfield',
                    fieldLabel: '推荐人单位',
                    width:300,
                    name: 'recommendedUnit',
                    id: 'recommendedUnit',
                    hidden:true
                }]
            }, {
                items: [{
                    xtype:'combobox',
                    id:'customerStar',
                    store: intentionLevelStore,
                    displayField: "text",
                    valueField: "value",
                    fieldLabel:'<font style="color:#e90000;">*</font>意向等级',
                    width:300,
                    typeAhead: true,
                    name:'intentionLevel',
                    allowBlank:false,
                    blankText:'不能为空',
                    queryMode:'local',
                    listeners:{
                        'change':function(value){
                            if(value.lastValue=="1"){
                                userOption('1');
                            }else if(value.lastValue=="2"){
                                userOption('2');
                            }else if(value.lastValue=="3"){
                                userOption('3');
                            }else if(value.lastValue=="4"){
                                userOption('4');
                            }else if(value.lastValue=="5"){
                                userOption('5');
                            }
                        }
                    },
                    typeAhead:false,
                    editable:false
                },{
                    xtype:'combobox',
                    fieldLabel: '<font style="color:#e90000;">*</font>获知途径',
                    width:300,
                    name: 'informedWay',
                    store: informedWayStore,
                    id: 'informedWay',
                    displayField: "codeName",
                    valueField: "id",
                    queryMode:'local',
                    listeners:{
                        change: function(value){
                            //手动改变获取到的值类型
                            var record = informedWayStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('informedWay').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('informedWay').setValue(parseInt(value.lastValue));
                            }

                            var displayValue = Ext.getCmp('informedWay').getRawValue();
                            //为全员营销或者外部推荐时，展示推荐人信息
                            if(displayValue == "全员营销"|| displayValue == "外部推荐时"){
                                Ext.getCmp('recommendedCategory').show();
                                Ext.getCmp('recommendedName').show();
                                Ext.getCmp('recommendedMobile').show();
                                Ext.getCmp('recommendedUnit').show();
                            }else{
                                Ext.getCmp('recommendedCategory').hide();
                                Ext.getCmp('recommendedName').hide();
                                Ext.getCmp('recommendedMobile').hide();
                                Ext.getCmp('recommendedUnit').hide();
                            }
                        }
                    },
                    allowBlank:false,
                    blankText:'不能为空',
                    typeAhead:false,
                    editable:false
                }, {
                    xtype:'numberfield',
                    fieldLabel: '备用号码',
                    name: 'peMobile',
                    allowBlank: true,
                    maxLength: 11,
                    hideTrigger: true,
                    id: 'peMobile',
                    regex: /^1[3|4|5|6|7|8|9]\d{9}$/,
                    listeners:{
                        blur: function(value){
                            if(value.lastValue){
                                //在验证手机号码是否正确
                                Ext.Ajax.request({
                                    url: contextPath+'/common/mobile/verifyingMobile',
                                    params: {
                                        mobile: value.lastValue,
                                    },
                                    method: 'POST',
                                    async: false,
                                    success: function(response){
                                        var text = Ext.decode(response.responseText);
                                        if(text.result=="1"){
                                            if(text.flag != "1"){
                                                Ext.MessageBox.alert('提示', '请输入正确的手机号码');
                                            }
                                        }
                                    }
                                });
                                //判断手机号是否存在
                                var projectId = Ext.getCmp('cbstore').getValue();
                                var customerId = Ext.getCmp('customerId').getValue();
                                Ext.Ajax.request({
                                    url: contextPath+'/customer/customer/customerPhone',
                                    params: {
                                        phone: value.lastValue,
                                        projectId:projectId,
                                        id: customerId
                                    },
                                    method: 'POST',
                                    success: function(response){
                                        var text = Ext.decode(response.responseText);
                                        if(text.res=="1"){
                                            Ext.MessageBox.alert('提示', '客戶已存在!');
                                        }else if(text.res=="10000"){
                                            Ext.MessageBox.alert("系统提示","系统异常!");
                                        }
                                    }
                                });
                            }
                        }
                    }
                },{
                    xtype:'combobox',
                    fieldLabel: '推荐人类别',
                    width:300,
                    id:'recommendedCategory',
                    name: 'recommendedCategory',
                    store: recommendedCategoryStore,
                    displayField: "text",
                    valueField: "value",
                    hidden:true,
                    typeAhead:false,
                    editable:false
                }, {
                    xtype:'numberfield',
                    fieldLabel: '推荐人手机',
                    width:300,
                    name: 'recommendedMobile',
                    id:'recommendedMobile',
                    hidden:true,
                    blankText:'不能为空',
                    maxLength:11,
                    hideTrigger:true,
                    regex: /^1[3|4|5|6|7|8|9]\d{9}$/,
                    listeners:{
                        blur: function(value){
                            if(value.lastValue){
                                //在验证手机号码是否正确
                                Ext.Ajax.request({
                                    url: contextPath+'/common/mobile/verifyingMobile',
                                    params: {
                                        mobile: value.lastValue,
                                    },
                                    method: 'POST',
                                    async: false,
                                    success: function(response){
                                        var text = Ext.decode(response.responseText);
                                        if(text.result=="1"){
                                            if(text.flag != "1"){
                                                Ext.MessageBox.alert('提示', '请输入正确的手机号码');
                                            }
                                        }
                                    }
                                });
                            }
                        }
                    }
                },{
                    xtype:'textfield',
                    fieldLabel: 'ID',
                    width:300,
                    name: 'id',
                    id:'customerId',
                    hidden:true
                }]
            }]
        };
        var items=[row_1,row_2];
        var initConfigg = {
            title:"客户基本信息",
            bodyStyle: 'padding:5px 5px 0',
            minHeight: 100,
            fieldDefaults: {
                labelAlign: 'left',
                msgTarget: 'side',
                margin: 5
            },
            items:items
        };
        Ext.apply(this,initConfigg);
        this.callParent(arguments);
    }
});

Ext.define('customer.payDeposit.add.customerPanel',{
    extend : 'Ext.form.Panel',
    initComponent:function(){
        rqFocusIdStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });
        // rqFocusIdStore.load({
        // 	callback: function(records, operation, success){
        // 		rqFocusIdStore.filter("delFlag", 0);
        // 	}
        // });

        rqServicesIdStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });
        // rqServicesIdStore.load({
        // 	callback: function(records, operation, success){
        // 		rqServicesIdStore.filter("delFlag", 0);
        // 	}
        // });

        rqTheirMotivesStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });
        // rqTheirMotivesStore.load({
        // 	callback: function(records, operation, success){
        // 		rqTheirMotivesStore.filter("delFlag", 0);
        // 	}
        // });

        var rqDemandAreaStoreList = [
            {"value":"1","text":"50㎡以下"},
            {"value":"2","text":"50-70㎡"},
            {"value":"3","text":"70-90㎡"},
            {"value":"4","text":"90-120㎡"},
            {"value":"5","text":"120-140㎡"},
            {"value":"6","text":"140-160㎡"},
            {"value":"7","text":"160-180㎡"},
            {"value":"8","text":"180-200㎡"},
            {"value":"9","text":"200㎡以上"}
        ];
        var rqDemandAreaStore = Ext.data.Store({
            autoDestroy: true,
            fields :["value","text"],
            data : rqDemandAreaStoreList
        });
        rqDemandFloorStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });
        // rqDemandFloorStore.load({
        // 	callback: function(records, operation, success){
        // 		rqDemandFloorStore.filter("delFlag", 0);
        // 	}
        // });
        rqLifeSupportStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });
        // rqLifeSupportStore.load({
        // 	callback: function(records, operation, success){
        // 		rqLifeSupportStore.filter("delFlag", 0);
        // 	}
        // });
        rqCourtyardFunctionStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });
        // rqCourtyardFunctionStore.load({
        // 	callback: function(records, operation, success){
        // 		rqCourtyardFunctionStore.filter("delFlag", 0);
        // 	}
        // });
        var rqBudgetPriceStoreList = [
            {"value":"1","text":"5000元/㎡以下"},
            {"value":"2","text":"5000-5500元/㎡"},
            {"value":"3","text":"5500-6000元/㎡"},
            {"value":"4","text":"6000-8000元/㎡"},
            {"value":"5","text":"8000-10000元/㎡"},
            {"value":"6","text":"10000-12000元/㎡"},
            {"value":"7","text":"12000-14000元/㎡"},
            {"value":"8","text":"14000-16000元/㎡"},
            {"value":"9","text":"16000-18000元/㎡"},
            {"value":"10","text":"18000-20000元/㎡"},
            {"value":"11","text":"20000-22000元/㎡"},
            {"value":"12","text":"22000-25000元/㎡"},
            {"value":"13","text":"25000-28000元/㎡"},
            {"value":"14","text":"28000-30000元/㎡"},
            {"value":"15","text":"30000元/㎡以上"}
        ];
        var rqBudgetPriceStore = Ext.data.Store({
            autoDestroy: true,
            fields :["value","text"],
            data : rqBudgetPriceStoreList
        });
        var rqBudgetSumpriceStoreList = [
            {"value":"1","text":"50万元以下"},
            {"value":"2","text":"50-80万元"},
            {"value":"3","text":"80-100万元"},
            {"value":"4","text":"100-150万元"},
            {"value":"5","text":"150-200万元"},
            {"value":"6","text":"200-250万元"},
            {"value":"7","text":"250-300万元"},
            {"value":"8","text":"300-400万元"},
            {"value":"9","text":"400-500万元"},
            {"value":"10","text":"500-600万元"},
            {"value":"11","text":"600-800万元"},
            {"value":"12","text":"800-1000万元"},
            {"value":"13","text":"1000万元以上"}
        ];
        var rqBudgetSumpriceStore = Ext.data.Store({
            autoDestroy: true,
            fields :["value","text"],
            data : rqBudgetSumpriceStoreList
        });

        familyJieStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });
        // familyJieStore.load({
        // 	callback: function(records, operation, success){
        // 		familyJieStore.filter("delFlag", 0);
        // 	}
        // });

        var me=this;
        var row_1={
            fieldDefaults: {
                labelAlign: 'top',
                msgTarget: 'side'
            },
            border: false,
            defaults: {
                border: false,
                xtype: 'panel',
                flex: 1,
                layout: 'anchor'
            },
            layout: 'hbox',items: [{
                items: [{
                    xtype:'combobox',
                    id:'rqTheirMotives',
                    store: rqTheirMotivesStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'置业动机',
                    width:300,
                    typeAhead: true,
                    name:'rqTheirMotives',
                    /*allowBlank:false,
                    blankText:'不能为空',*/
                    typeAhead:false,
                    editable:false,
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            var record = rqTheirMotivesStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('rqTheirMotives').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('rqTheirMotives').setValue(parseInt(value.lastValue));
                            }
                        }
                    }
                }, {
                    xtype:'combobox',
                    id:'rqDemandArea',
                    store: rqDemandAreaStore,
                    displayField: "text",
                    valueField: "value",
                    fieldLabel:'需求面积',
                    width:300,
                    typeAhead: true,
                    name:'rqDemandArea',
                    typeAhead:false,
                    editable:false
                }, {
                    xtype:'combobox',
                    id:'rqServicesId',
                    store: rqServicesIdStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'生活服务',
                    width:300,
                    name:'rqServicesId',
                    typeAhead:false,
                    editable:false,
                    multiSelect : true,
                    queryMode:'local'
                }, {
                    xtype:'combobox',
                    id:'rqBudgetSumprice',
                    store: rqBudgetSumpriceStore,
                    displayField: "text",
                    valueField: "value",
                    fieldLabel:'预算总价',
                    width:300,
                    typeAhead: true,
                    name:'rqBudgetSumprice',
                    typeAhead:false,
                    editable:false
                },{
                    xtype:'combobox',
                    id:'rqCourtyardFunction',
                    store: rqCourtyardFunctionStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'希望庭院具备功能',
                    width:300,
                    typeAhead: true,
                    name:'rqCourtyardFunction',
                    typeAhead:false,
                    editable:false,
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            var record = rqCourtyardFunctionStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('rqCourtyardFunction').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('rqCourtyardFunction').setValue(parseInt(value.lastValue));
                            }
                        }
                    }
                },{
                    xtype:'combobox',
                    fieldLabel:'付款方式',
                    typeAhead: true,
                    name:'rqPaymentMethod',
                    id:'rqPaymentMethod',
                    displayField: "des",
                    width:300,
                    valueField: "no",
                    store:storeMethed(paymentMethod),
                    typeAhead:false,
                    editable:false
                },{

                    xtype:'combobox',
                    fieldLabel:'意向物业类型',
                    typeAhead: true,
                    name:'yixiangwuyeType',
                    width:300,
                    id:'yixiangwuyeType',
                    displayField: "des",
                    valueField: "no",
                    store:storeMethed(yixiangwuyeType),
                    typeAhead:false,
                    editable:false

                },{
                    xtype:'combobox',
                    fieldLabel:'购买车位',
                    typeAhead: true,
                    width:300,
                    name:'buyCar',
                    id:'buyCar',
                    displayField: "des",
                    valueField: "no",
                    store:storeMethed(buyCarEnum),
                    typeAhead:false,
                    editable:false

                }]
            }, {
                items: [{
                    xtype:'combobox',
                    id:'rqFocusId',
                    store: rqFocusIdStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'关注重点',
                    width:300,
                    name:'rqFocusId',
                    typeAhead:false,
                    editable:false,
                    multiSelect : true,
                    queryMode:'local'
                },{
                    xtype:'combobox',
                    id:'rqDemandFloor',
                    store: rqDemandFloorStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'需求楼层',
                    width:300,
                    name:'rqDemandFloor',
                    typeAhead:false,
                    editable:false,
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            var record = rqDemandFloorStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('rqDemandFloor').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('rqDemandFloor').setValue(parseInt(value.lastValue));
                            }
                        }
                    }
                },{
                    xtype:'combobox',
                    id:'rqLifeSupport',
                    store: rqLifeSupportStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'生活配套',
                    width:300,
                    name:'rqLifeSupport',
                    typeAhead:false,
                    editable:false,
                    multiSelect : true,
                    queryMode:'local'
                },{
                    xtype:'combobox',
                    id:'rqBudgetPrice',
                    store: rqBudgetPriceStore,
                    displayField: "text",
                    valueField: "value",
                    fieldLabel:'预算单价',
                    width:300,
                    typeAhead: true,
                    name:'rqBudgetPrice',
                    typeAhead:false,
                    editable:false
                },{
                    xtype:'numberfield',
                    fieldLabel: '庭院需求面积',
                    width:300,
                    name: 'rqCourtyardArea',
                    id:'rqCourtyardArea',
                    hideTrigger:true,
                    maxLength:4
                },{
                    xtype:'combobox',
                    fieldLabel: '家庭结构',
                    name: 'familyJie',
                    width:300,
                    displayField: "codeName",
                    valueField: "id",
                    id:'familyJie',
                    store: familyJieStore,
                    typeAhead:false,
                    editable:false,
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            var record = familyJieStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('familyJie').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('familyJie').setValue(parseInt(value.lastValue));
                            }
                        }
                    }
                },{
                    xtype:'combobox',
                    fieldLabel: '需求户型规格',
                    name: 'xuqiuhuxingType',
                    width:300,
                    id:'xuqiuhuxingType',
                    displayField: "des",
                    valueField: "no",
                    store:storeMethed(xuQiuHuXingEnum),
                    typeAhead:false,
                    editable:false

                }]
            }]
        };
        var columns = [{
            text : "户型",
            dataIndex : 'houseTypeId',
            width:'50%',
            editor: {
                xtype:'combobox',
                id:'houseTypeId',
                store: houseTypeIdStore,
                displayField: "houseTypeName",
                valueField: "id",
                name:'houseTypeId',
                queryMode:'local',
                typeAhead:false,
                editable:false
            },
            renderer:function(value, cellmeta, record, rowIndex, columnIndex, store){
                if(value){
                    var index = houseTypeIdStore.find('id',value);
                    if(index!=-1){
                        return houseTypeIdStore.getAt(index).data.houseTypeName;
                    }  else{
                        return	record.data.houseTypeName;
                    }
                }
            }
        },{
            text:'操作',
            xtype : 'actioncolumn',
            width:'40%',
            items:[{
                iconCls:'icon-delete',
                tooltip: '删除',
                handler: function(grid, rowIndex, colIndex) {
                    gridStore2.removeAt(rowIndex);
                }
            }]
        }];


//		var gridStoreg = Ext.create('Ext.data.Store', {
//	        fields: ["id","houseTypeName"],
//	        pageSize: 15,  //页容量5条数据
//	        //是否在服务端排序 （true的话，在客户端就不能排序）
//	        remoteSort: false,
//	        proxy: {
//	            type: 'ajax',
//	            url: contextPath+'/customer/customer/houseTypeList',
//	            actionMethods: { read: 'POST' },
//	            reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
//	                type: 'json', //返回数据类型为json格式
//	                root: 'rows',  //数据
//	                totalProperty: 'total' //数据总条数
//	            }
//	        },
//	        autoLoad: true  //即时加载数据
//	    });
//
//		gridStoreg.on("beforeload",function(){
//	        Ext.apply(gridStoreg.proxy.extraParams,{customerId:customerId});
//	    });
        var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
            clicksToEdit: 1
        });
        var row_2=Ext.create('Ext.grid.Panel', {
            id:'huxingGridPanel',
            title:"关注户型",
            minHeight:100,
            columnLines: true,
            viewConfig: {
                stripeRows: true
            },
            store : gridStore2,
            columns : columns,
            plugins: [cellEditing],
            tbar:[{text:'新增',iconCls:'icon-add',
                handler:function(){
                    Ext.define('Record', {
                        extend: 'Ext.data.Model',
                    });
                    var record  = new Record();
                    gridStore2.insert(0, record);
                    cellEditing.startEditByPosition({
                        row: 0,
                        column: 0
                    });
                }
            }
            ]
        });
        var columns3 = [{
            text : "团名",
            dataIndex : 'premisesId',
            width:'50%',
            editor: {
                xtype:'combobox',
                id:'premisesId',
                store: premisesIdStore,
                displayField: "groupName",
                valueField: "id",
                name:'premisesId',
                queryMode:'local',
                typeAhead:false,
                editable:false,
                listeners:{
                    'change':function(value){
                        var projectId = Ext.getCmp('cbstore').getValue();
                        roomIdStore.load({
                            params:{
                                'projectId':projectId,
                                'premisesId':value.lastValue
                            }
                        });
                    }
                }
            },
            renderer:function(value, cellmeta, record, rowIndex, columnIndex, store){
                if(value){
                    var index = premisesIdStore.find('id',value);
                    if(index!=-1){
                        return premisesIdStore.getAt(index).data.groupName;
                    }  else{
                        return	record.data.groupName;
                    }
                }
            }
        },{
            text:'操作',
            xtype : 'actioncolumn',
            width:'40%',
            items:[{
                iconCls:'icon-delete',
                tooltip: '删除',
                handler: function(grid, rowIndex, colIndex) {
                    gridStore3.removeAt(rowIndex);
                }
            }]
        }];

//		var gridStoreg2 = Ext.create('Ext.data.Store', {
//	        fields: ["id","groupName"],
//	        pageSize: 15,  //页容量5条数据
//	        //是否在服务端排序 （true的话，在客户端就不能排序）
//	        remoteSort: false,
//	        proxy: {
//	            type: 'ajax',
//	            url: contextPath+'/customer/customer/premisesList',
//	            actionMethods: { read: 'POST' },
//	            reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
//	                type: 'json', //返回数据类型为json格式
//	                root: 'rows',  //数据
//	                totalProperty: 'total' //数据总条数
//	            }
//	        },
//	        autoLoad: true  //即时加载数据
//	    });
//
//		gridStoreg2.on("beforeload",function(){
//	        Ext.apply(gridStoreg2.proxy.extraParams,{customerId:customerId});
//	    });
        var cellEditing3 = Ext.create('Ext.grid.plugin.CellEditing', {
            clicksToEdit: 1
        });
        var row_3=Ext.create('Ext.grid.Panel', {
            id:'yixiangGridPanel',
            title:"意向组团",
            minHeight:100,
            columnLines: true,
            viewConfig: {
                stripeRows: true
            },
            store : gridStore3,
            columns : columns3,
            plugins: [cellEditing3],
            tbar:[{text:'新增',iconCls:'icon-add',
                handler:function(){
                    Ext.define('Record', {
                        extend: 'Ext.data.Model',
                    });
                    var record  = new Record();
                    gridStore3.insert(0, record);
                    cellEditing3.startEditByPosition({
                        row: 0,
                        column: 0
                    });
                }
            }
            ]
        });
//		var gridStoreg3 = Ext.create('Ext.data.Store', {
//	        fields: ["id","combinedName"],
//	        pageSize: 15,  //页容量5条数据
//	        //是否在服务端排序 （true的话，在客户端就不能排序）
//	        remoteSort: false,
//	        proxy: {
//	            type: 'ajax',
//	            url: contextPath+'/customer/customer/roomList',
//	            actionMethods: { read: 'POST' },
//	            reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
//	                type: 'json', //返回数据类型为json格式
//	                root: 'rows',  //数据
//	                totalProperty: 'total' //数据总条数
//	            }
//	        },
//	        autoLoad: true  //即时加载数据
//	    });
//
//		gridStoreg3.on("beforeload",function(){
//	        Ext.apply(gridStoreg3.proxy.extraParams,{customerId:customerId});
//	    });

        var columns4 = [{
            text : "房间",
            dataIndex : 'roomId',
            width:'50%',
            editor: {
                xtype:'combobox',
                id:'roomId',
                store: roomIdStore,
                displayField: "combinedName",
                valueField: "id",
                name:'roomId',
                queryMode:'local',
                typeAhead:false,
                editable:false
            },
            renderer:function(value, cellmeta, record, rowIndex, columnIndex, store){
                if(value){
                    var index = roomIdStore.find('id',value);
                    if(index!=-1){
                        return roomIdStore.getAt(index).data.combinedName;
                    }  else{
                        return	record.data.combinedName;
                    }
                }
            }
        },{
            text:'操作',
            xtype : 'actioncolumn',
            width:'40%',
            items:[{
                iconCls:'icon-delete',
                tooltip: '删除',
                handler: function(grid, rowIndex, colIndex) {
                    gridStore4.removeAt(rowIndex);
                }
            }]
        }];

        var cellEditing4 = Ext.create('Ext.grid.plugin.CellEditing', {
            clicksToEdit: 1
        });
        var row_4=Ext.create('Ext.grid.Panel', {
            id:'fangyuanGridPanel',
            title:"意向房源",
            minHeight:100,
            columnLines: true,
            viewConfig: {
                stripeRows: true
            },
            store : gridStore4,
            columns : columns4,
            plugins: [cellEditing4],
            tbar:[{text:'新增',iconCls:'icon-add',
                handler:function(){
                    Ext.define('Record', {
                        extend: 'Ext.data.Model',
                    });
                    var record  = new Record();
                    gridStore4.insert(0, record);
                    cellEditing4.startEditByPosition({
                        row: 0,
                        column: 0
                    });
                }
            }
            ]
        });
        var row_5={
            defaults: {
                border: false,
                xtype: 'panel',
                flex: 1
            },
            border: false,
            layout: 'hbox',
            items: [{
                items:row_2
            },{
                items:row_3
            }, {
                items:row_4
            }]
        };
        var items=[row_1,row_5];//,row_2,row_3,row_4
        var initConfigg = {
            title:"客户购房需求",
            minHeight:320,
            fieldDefaults: {
                labelAlign: 'left',
                msgTarget: 'side',
                margin: 5
            },
            scrollable:true,
            items:items
        };
        Ext.apply(this,initConfigg);
        this.callParent(arguments);
    }
});

Ext.define('customer.payDeposit.add.firstjiePanel',{
    extend : 'Ext.form.Panel',
    initComponent:function(){
        ftContactWayStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });
        // ftContactWayStore.load({
        // 	callback: function(records, operation, success){
        // 		ftContactWayStore.filter("delFlag", 0);
        // 	}
        // });

        var row_1={
            fieldDefaults: {
                labelAlign: 'left',
                msgTarget: 'side'
            },
            border: false,
            defaults: {
                border: false,
                xtype: 'panel',
                flex: 1,
                layout: 'anchor'
            },
            layout: 'column',
            items: [{
                items: [{
                    xtype:'combobox',
                    id:'ftContactWay',
                    store: ftContactWayStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'<font style="color:#e90000;">*</font>接触方式1',
                    width:300,
                    //typeAhead: true,
                    name:'ftContactWay',
                    typeAhead:false,
                    editable:false,
                    allowBlank:false,
                    blankText:'不能为空',
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            var record = ftContactWayStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('ftContactWay').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('ftContactWay').setValue(parseInt(value.lastValue));
                            }

                        }
                    }
                }, {
                    xtype:'datefield',
                    fieldLabel: '<font style="color:#e90000;">*</font>接触时间',
                    width:300,
                    name: 'ftContactTimes',
                    format: 'Y-m-d H:i',
                    id:'ftContactTimes',
                    allowBlank:false,
                    blankText:'不能为空',
                    editable:false,
                    readOnly:true
                }, {
                    xtype:'textarea',
                    fieldLabel: '<font style="color:#e90000;">*</font>沟通内容',
                    width:300,
                    name:'ftContactContent',
                    id:'ftContactContent',
                    minWidth:1100,
                    allowBlank:false,
                    blankText:'不能为空'
                }]
            }
//				, {
//		            items: []
//		        }
            ]
        };
        var items=[row_1];
        var initConfigg = {
            title:"首次接触信息",
            minHeight:100,
            fieldDefaults: {
                labelAlign: 'left',
                msgTarget: 'side',
                margin: 5
            },
            items:items
        };
        Ext.apply(this,initConfigg);
        this.callParent(arguments);
    }
});
Ext.define('customer.payDeposit.add.membergePanel',{
    extend : 'Ext.form.Panel',
    initComponent:function(){
        peFrameBrandIdStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });
        // peFrameBrandIdStore.load({
        // 	callback: function(records, operation, success){
        // 		peFrameBrandIdStore.filter("delFlag", 0);
        // 	}
        // });

        peHobbyIdStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });
        // peHobbyIdStore.load({
        // 	callback: function(records, operation, success){
        // 		peHobbyIdStore.filter("delFlag", 0);
        // 	}
        // });

        peDocumentTypeStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });
        // peDocumentTypeStore.load({
        // 	callback: function(records, operation, success){
        // 		peDocumentTypeStore.filter("delFlag", 0);
        // 	}
        // });

        var peDomicilePlaceStoreList = [
            {"value":"1","text":"本地"},
            {"value":"2","text":"省外"},
            {"value":"3","text":"省内"},
            {"value":"4","text":"境外"}
        ];
        var peDomicilePlaceStore = Ext.data.Store({
            autoDestroy: true,
            fields :["value","text"],
            data : peDomicilePlaceStoreList
        });
        var peHouseholdIncomeStoreList = [
            {"value":"1","text":"20万元以下"},
            {"value":"2","text":"20-30万元"},
            {"value":"3","text":"30-50万元"},
            {"value":"4","text":"50-80万元"},
            {"value":"5","text":"80-100万元"},
            {"value":"6","text":"100-200万元"},
            {"value":"7","text":"200-300万元"},
            {"value":"8","text":"300-500万元"},
            {"value":"9","text":"500万元以上"}
        ];
        var peHouseholdIncomeStore = Ext.data.Store({
            autoDestroy: true,
            fields :["value","text"],
            data : peHouseholdIncomeStoreList
        });
        peActivityTypeStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });
        // peActivityTypeStore.load({
        // 	callback: function(records, operation, success){
        // 		peActivityTypeStore.filter("delFlag", 0);
        // 	}
        // });

        //省份
        var peResidenceProvinceIdStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["areaName", "id"],
            proxy:{
                type:'ajax',
                url:contextPath+'/customer/customer/provList',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            },
            autoLoad:true
        });
        //工作省
        var peWorkaroundProvinceIdStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["areaName", "id"],
            proxy:{
                type:'ajax',
                url:contextPath+'/customer/customer/provList',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            },
            autoLoad:true
        });

        riChangXinXiStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });
        // riChangXinXiStore.load({
        // 	callback: function(records, operation, success){
        // 		riChangXinXiStore.filter("delFlag", 0);
        // 	}
        // });

        peAcademicQualificationsStore= new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName","delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            },
            autoLoad:false
        });

        congshihangyeStore= new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName","delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            },
            autoLoad:false
        });

        companyXingzhiStore= new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName","delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            },
            autoLoad:false
        });

        var row_1={
            fieldDefaults: {
                labelAlign: 'left',
                msgTarget: 'side'
            },
            border: false,
            defaults: {
                border: false,
                xtype: 'panel',
                flex: 1,
                layout: 'anchor'
            },
            layout: 'hbox',
            items: [{
                items: [{
                    xtype:'combobox',
                    id:'peDocumentType',
                    store: peDocumentTypeStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'证件类型',
                    width:300,
                    typeAhead: true,
                    name:'peDocumentType',
                    typeAhead:false,
                    editable:false,
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            var record = peDocumentTypeStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('peDocumentType').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('peDocumentType').setValue(parseInt(value.lastValue));
                            }
                        }
                    }
                }, {
                    xtype:'textfield',
                    fieldLabel: '证件号码',
                    width:300,
                    name: 'peDocumentNumber',
                    id:'peDocumentNumber',
                    regex: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
                }, {
                    xtype:'datefield',
                    fieldLabel: '出生日期',
                    width:300,
                    name: 'peBirth',
                    format: 'Y-m-d',
                    id:'peBirth'
                }, {
                    xtype:'textfield',
                    fieldLabel: '年龄',
                    width:300,
                    name: 'peAge',
                    id:'peAge',
                    maxLength:3,
                    regex:/^[1-9]\d*$/
                }, {
                    xtype:'textfield',
                    fieldLabel: '固定电话',
                    width:300,
                    name: 'peTelephone',
                    id:'peTelephone',
                    maxLength:12,
                    regex:/(^[0-9]{3,4}\-[0-9]{7,8}$)|(^[0-9]{7,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/
                }, {
                    xtype:'textfield',
                    fieldLabel: '邮箱',
                    width:300,
                    name: 'peEmail',
                    id:'peEmail',
                    vtype:'email'
                }, {
                    xtype:'textfield',
                    fieldLabel: '微信',
                    width:300,
                    name: 'peWechat',
                    id:'peWechat'
                }, {
                    xtype:'combobox',
                    id:'peFrameBrandId',
                    store: peFrameBrandIdStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'车驾品牌',
                    width:300,
                    typeAhead: true,
                    name:'peFrameBrandId',
                    typeAhead:false,
                    editable:false,
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            var record = peFrameBrandIdStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('peFrameBrandId').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('peFrameBrandId').setValue(parseInt(value.lastValue));
                            }

                        }
                    }
                }, {
                    xtype:'combobox',
                    id:'peActivityType',
                    store: peActivityTypeStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'乐于参加的活动类型',
                    width:300,
                    name:'peActivityType',
                    typeAhead:false,
                    multiSelect : true,
                    editable:false,
                    queryMode:'local'
                },{
                    xtype:'textfield',
                    fieldLabel: '邮编',
                    id:'pePostcode',
                    width:300,
                    name: 'pePostcode',
                    maxLength:6,
                    regex:/^[1-9]\d*$/
                },{
                    xtype:'combobox',
                    fieldLabel: '学历',
                    name: 'peAcademicQualifications',
                    id:'peAcademicQualifications',
                    displayField: "codeName",
                    width:300,
                    valueField: "id",
                    store:peAcademicQualificationsStore,
                    typeAhead:false,
                    editable:false,
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            var record = peAcademicQualificationsStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('peAcademicQualifications').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('peAcademicQualifications').setValue(parseInt(value.lastValue));
                            }

                        }
                    }

                },{
                    xtype:'combobox',
                    fieldLabel: '从事行业',
                    name: 'congshihangye',
                    id:'congshihangye',
                    width:300,
                    displayField: "codeName",
                    valueField: "id",
                    store:congshihangyeStore,
                    typeAhead:false,
                    editable:false,
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            var record = congshihangyeStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('congshihangye').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('congshihangye').setValue(parseInt(value.lastValue));
                            }

                        }
                    }
                },{
                    xtype:'combobox',
                    fieldLabel: '公司性质',
                    name: 'companyXingzhi',
                    id:'companyXingzhi',
                    width:300,
                    displayField: "codeName",
                    valueField: "id",
                    store:companyXingzhiStore,
                    typeAhead:false,
                    editable:false,
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            var record = companyXingzhiStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('companyXingzhi').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('companyXingzhi').setValue(parseInt(value.lastValue));
                            }

                        }
                    }
                },{
                    xtype:'textfield',
                    fieldLabel: '公司年营业额',
                    id:'companyYingye',
                    width:300,
                    name: 'companyYingye',
                    maxLength:11

                },{
                    xtype:'combobox',
                    fieldLabel: '是否员工',
                    name: 'isYuangong',
                    displayField: "des",
                    id:'isYuangong',
                    width:300,
                    valueField: "no",
                    store:storeMethed(isAvlidEnum),
                    typeAhead:false,
                    editable:false
                }]
            }, {
                items: [{
                    xtype:'combobox',
                    id:'peDomicilePlace',
                    store: peDomicilePlaceStore,
                    displayField: "text",
                    valueField: "value",
                    fieldLabel:'户籍所在地',
                    width:300,
                    typeAhead: true,
                    name:'peDomicilePlace',
                    typeAhead:false,
                    editable:false
                }, {
                    xtype:'textfield',
                    fieldLabel: '联系地址',
                    width:300,
                    name: 'peContactAddress',
                    id:'peContactAddress'
                }, {
                    items: [{
                        xtype : "container",
                        layout : "hbox",
                        items : [{
                            xtype:'combobox',
                            id:'peResidenceProvinceId',
                            store: peResidenceProvinceIdStore,
                            displayField: "areaName",
                            valueField: "id",
                            fieldLabel:'居住地',
                            name:'peResidenceProvinceId' ,
                            typeAhead: true,
                            width:300,
                            listeners:{
                                'select':function(value){
                                    Ext.getCmp('peResidenceCityId').setValue("");
                                    Ext.getCmp('peResidenceAreaId').setValue("");
                                    peResidenceCityIdStore.load({
                                        params:{
                                            'id':value.lastValue
                                        }
                                    });
                                }
                            },/*
					            allowBlank:false,
					            blankText:'不能为空',*/
                            typeAhead:false,
                            editable:false
                        },{
                            xtype:'combobox',
                            id:'peResidenceCityId',
                            store: peResidenceCityIdStore,
                            displayField: "areaName",
                            valueField: "id",
                            width:100,
                            // fieldLabel:'居住市',
                            name:'peResidenceCityId' ,
                            typeAhead: true,
                            listeners:{
                                'select':function(value){
                                    Ext.getCmp('peResidenceAreaId').setValue("");
                                    peResidenceAreaIdStore.load({
                                        params:{
                                            'id':value.lastValue
                                        }
                                    });
                                }
                            },
                            queryMode : 'local',
                            /*allowBlank:false,
                            blankText:'不能为空',*/
                            typeAhead:false,
                            editable:false
                        },{
                            xtype:'combobox',
                            id:'peResidenceAreaId',
                            store: peResidenceAreaIdStore,
                            displayField: "areaName",
                            valueField: "id",
                            width:100,
                            //fieldLabel:'居住区',
                            typeAhead: true,
                            name:'peResidenceAreaId',
                            queryMode : 'local',
                            /*allowBlank:false,
                            blankText:'不能为空',*/
                            typeAhead:false,
                            editable:false
                        }]
                    }]
                }, {
                    xtype:'textfield',
                    fieldLabel: '小区',
                    width:300,
                    name: 'pePlot',
                    id:'pePlot'
                }, {
                    xtype:'textfield',
                    fieldLabel: '详细地址',
                    width:300,
                    name: 'peDetailedAddress',
                    id:'peDetailedAddress'
                }, {

                    items: [{
                        xtype : "container",
                        layout : "hbox",
                        items : [
                            {
                                xtype:'combobox',
                                id:'peWorkaroundProvinceId',
                                store: peWorkaroundProvinceIdStore,
                                displayField: "areaName",
                                valueField: "id",
                                width:300,
                                fieldLabel:'工作区',
                                typeAhead: true,
                                listeners:{
                                    'select':function(value){
                                        Ext.getCmp('peWorkaroundCityId').setValue("");
                                        Ext.getCmp('peWorkaroundAreaId').setValue("");
                                        peWorkaroundCityIdStore.load({
                                            params:{
                                                'id':value.lastValue
                                            }
                                        });
                                    }
                                },
                                name:'peWorkaroundProvinceId',
                                /*allowBlank:false,
                                blankText:'不能为空',*/
                                typeAhead:false,
                                editable:false
                            },{
                                xtype:'combobox',
                                id:'peWorkaroundCityId',
                                store: peWorkaroundCityIdStore,
                                displayField: "areaName",
                                valueField: "id",
                                width:100,
                                typeAhead: true,
                                listeners:{
                                    'select':function(value){
                                        Ext.getCmp('peWorkaroundAreaId').setValue("");
                                        peWorkaroundAreaIdStore.load({
                                            params:{
                                                'id':value.lastValue
                                            }
                                        });
                                    }
                                },
                                name:'peWorkaroundCityId',
                                queryMode : 'local',
                                /*allowBlank:false,
                                blankText:'不能为空',*/
                                typeAhead:false,
                                editable:false
                            },{
                                xtype:'combobox',
                                id:'peWorkaroundAreaId',
                                store: peWorkaroundAreaIdStore,
                                displayField: "areaName",
                                valueField: "id",
                                width:100,
                                typeAhead: true,
                                name:'peWorkaroundAreaId',
                                queryMode : 'local',
                                /*allowBlank:false,
                                blankText:'不能为空',*/
                                typeAhead:false,
                                editable:false
                            }
                        ]
                    }]
                }, {
                    xtype:'textfield',
                    fieldLabel: '详细地址',
                    width:300,
                    name: 'peWorkaroundAddress',
                    id:'peWorkaroundAddress'
                }, {
                    xtype:'combobox',
                    id:'peHouseholdIncome',
                    store: peHouseholdIncomeStore,
                    displayField: "text",
                    valueField: "value",
                    fieldLabel:'家庭年收入',
                    width:300,
                    typeAhead: true,
                    name:'peHouseholdIncome',
                    typeAhead:false,
                    editable:false
                }, {
                    xtype:'combobox',
                    id:'peHobbyId',
                    store: peHobbyIdStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'兴趣爱好',
                    width:300,
                    multiSelect : true,
                    queryMode:'local',
                    name:'peHobbyId',
                    typeAhead:false,
                    editable:false

                },{
                    xtype:'combobox',
                    fieldLabel: '是否有子女',
                    name: 'isZinv',
                    displayField: "des",
                    id:'isZinv',
                    width:300,
                    valueField: "no",
                    store:storeMethed(isAvlidEnum),
                    typeAhead:false,
                    editable:false
                },{
                    xtype:'combobox',
                    displayField: "text",
                    fieldLabel:'是否与老人同住',
                    id:'isLaoren',
                    name:'isLaoren',
                    width:300,
                    displayField: "des",
                    valueField: "no",
                    store:storeMethed(isAvlidEnum),
                    typeAhead:false,
                    editable:false
                },{
                    xtype:'textfield',
                    fieldLabel: 'QQ号码',
                    id:'qqNumber',
                    width:300,
                    name: 'qqNumber',
                    regex:/^[1-9]\d*$/,
                    maxLength:12
                },{
                    xtype:'combobox',
                    displayField: "text",
                    fieldLabel:'是否本公司业主',
                    name:'isYezhu',
                    id:'isYezhu',
                    displayField: "des",
                    width:300,
                    valueField: "no",
                    store:storeMethed(isOwnerCompanyEnum),
                    typeAhead:false,
                    editable:false
                },{
                    xtype:'combobox',
                    fieldLabel:'日常信息获取途径',
                    name:'richangxinxi',
                    width:300,
                    id:'richangxinxi',
                    displayField: "codeName",
                    valueField: "id",
                    store: riChangXinXiStore,
                    typeAhead:false,
                    multiSelect : true,
                    editable:false,
                    queryMode:'local'
                }]
            }]
        };
        var items=[row_1];
        var initConfigg = {
            title:"客户个人信息",
            minHeight:100,
            fieldDefaults: {
                labelAlign: 'left',
                msgTarget: 'side',
                margin: 5
            },
            items:items
        };
        Ext.apply(this,initConfigg);
        this.callParent(arguments);
    }
});
Ext.define('customer.payDeposit.add.jiatingPanel',{
    extend : 'Ext.form.Panel',
    initComponent:function(){
        documentTypeStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["codeName", "id"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            }
        });

        var relationshipList = [
            {"value":"1", "text":"父亲"},
            {"value":"2", "text":"母亲"},
            {"value":"3", "text":"丈夫"},
            {"value":"4", "text":"妻子"},
            {"value":"5", "text":"儿子"},
            {"value":"6", "text":"女儿"},
            {"value":"7", "text":"实际购房者"},
            {"value":"99", "text":"其他"}
        ];

        relationshipStore = new Ext.data.Store({
            autoDestroy: true,
            fields :["value","text"],
            data : relationshipList
        });

        var me=this;

        var columns = [{
            text : "姓名",
            dataIndex : 'memberName',
            width:'10%',
            editor: {
                xtype: 'textfield'
            }
        },{
            text : "手机号",
            dataIndex : 'mobile',
            width:'10%',
            editor: {
                xtype: 'textfield'
            }
        },{
            text : "成员关系",
            dataIndex : 'relationship',
            width:'10%',
            editor: new Ext.form.field.ComboBox({
                store: relationshipStore,
                queryMode: 'local',
                displayField: 'text',
                valueField: 'value',
                typeAhead:false,
                editable:false
            }),
            renderer:function(value,metadata,record){
                console.log("value = " + value);
                if(value){
                    var index = relationshipStore.find('value', parseInt(value));
                    console.log("index = " + index);
                    if(index!=-1){
                        return relationshipStore.getAt(index).data.text;
                    }
                    return value;
                }
            }
        },{
            text : "证件类型",
            dataIndex : 'documentType',
            width:'10%',
            editor: new Ext.form.field.ComboBox({
                store: documentTypeStore,
                queryMode: 'local',
                displayField: 'codeName',
                valueField: 'id',
                typeAhead:false,
                editable:false
            }),
            renderer:function(value,metadata,record){
                if(value){
                    var index = documentTypeStore.find('id',value);
                    if(index!=-1){
                        return documentTypeStore.getAt(index).data.codeName;
                    }
                    return value;
                }
            }
        }, {
            text : "证件号码",
            dataIndex : 'documentNumber',
            width:'10%',
            editor: {
                xtype: 'textfield',
                maxLength:18,
                regex: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
            }
        }, {
            text : "生日",
            dataIndex : 'birthday',
            width:'10%',
            editor: {
                xtype: 'datefield',
                format: 'Y-m-d'
            },
            renderer:function(value){
                if(value)
                    return Ext.Date.format(new Date(value),'Y-m-d')
            }
        }, {
            text : "结婚纪念日",
            dataIndex : 'marryday',
            width:'10%',
            editor: {
                xtype: 'datefield',
                format: 'Y-m-d'
            },
            renderer:function(value){
                if(value)
                    return Ext.Date.format(new Date(value),'Y-m-d')
            }
        }, {
            text:'操作',
            xtype : 'actioncolumn',
            items:[{
                iconCls:'icon-delete',
                tooltip: '删除',
                handler: function(grid, rowIndex, colIndex) {
                    gridStore.removeAt(rowIndex);
                }
            }]
        }];
        var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
            clicksToEdit: 1
        });

        gridStore = Ext.create('Ext.data.Store', {
            fields: ["id","memberName","documentType", "documentNumber"
                , "birthday", "relationship", "mobile", "marryday"],
            pageSize: 15,  //页容量5条数据
            //是否在服务端排序 （true的话，在客户端就不能排序）
            remoteSort: false,
            proxy: {
                type: 'ajax',
                url: contextPath+'/customer/customer/familyMemberList',
                actionMethods: { read: 'POST' },
                reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
                    type: 'json', //返回数据类型为json格式
                    root: 'rows',  //数据
                    totalProperty: 'total' //数据总条数
                }
            },
            autoLoad: true  //即时加载数据
        });

        gridStore.on("beforeload",function(){
            Ext.apply(gridStore.proxy.extraParams,{customerId:customerId});
        });

        var row_2=Ext.create('Ext.grid.Panel', {
            id:'familyMemberGridPanel',
            region : 'south',
            //title:"家庭（成员）情况",
            minHeight:100,
            columnLines: true,
            viewConfig: {
                stripeRows: true
            },
            store : gridStore,
            columns : columns,
            plugins: [cellEditing],
            tbar:[{text:'新增',iconCls:'icon-add',
                handler:function(){
                    Ext.define('Record', {
                        extend: 'Ext.data.Model',
                    });
                    var record  = new Record();
                    gridStore.insert(0, record);
                    cellEditing.startEditByPosition({
                        row: 0,
                        column: 0
                    });
                }
            }]
        });
        var items=[row_2];
        var initConfigg = {
            title:"家庭（成员）情况",
            minHeight:100,
            fieldDefaults: {
                labelAlign: 'left',
                msgTarget: 'side',
                margin: 5
            },
            items:items
        };
        Ext.apply(this,initConfigg);
        this.callParent(arguments);
    }
});
Ext.define('customer.payDeposit.add.zhuzhaiPanel',{
    extend : 'Ext.form.Panel',
    initComponent:function(){
        var reCurrentlyAreaStoreList = [
            {"value":"1","text":"50㎡以下"},
            {"value":"2","text":"50-70㎡"},
            {"value":"3","text":"70-90㎡"},
            {"value":"4","text":"90-120㎡"},
            {"value":"5","text":"120-140㎡"},
            {"value":"6","text":"140-160㎡"},
            {"value":"7","text":"160-180㎡"},
            {"value":"8","text":"180-200㎡"},
            {"value":"9","text":"200㎡以上"}
        ];
        var reCurrentlyAreaStore = Ext.data.Store({
            autoDestroy: true,
            fields :["value","text"],
            data : reCurrentlyAreaStoreList
        });
        reCurrentlyPropertyStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            },
            autoLoad:false
        });
        reCurrentlyStructureStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            },
            autoLoad:false
        });
        reCurrentlyHouseStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            },
            autoLoad:false
        });
        var row_1={
            fieldDefaults: {
                labelAlign: 'left',
                msgTarget: 'side'
            },
            border: false,
            defaults: {
                border: false,
                xtype: 'panel',
                flex: 1,
                layout: 'anchor'
            },
            layout: 'hbox',
            items: [{
                items: [{
                    xtype:'numberfield',
                    fieldLabel: '本地购房次数',
                    width:300,
                    name: 'reLocalPurchase',
                    id:'reLocalPurchase',
                    maxLength:2,
                    hideTrigger:true,
                    regex:/^[1-9]\d*$/
                }, {
                    xtype:'numberfield',
                    fieldLabel:'目前家庭持有住宅数',
                    width:300,
                    name:'reCurrentHoldings',
                    id:'reCurrentHoldings',
                    maxLength:2,
                    hideTrigger:true,
                    regex:/^[1-9]\d*$/
                }, {
                    xtype:'combobox',
                    id:'reCurrentlyArea',
                    store: reCurrentlyAreaStore,
                    displayField: "text",
                    valueField: "value",
                    fieldLabel:'目前居住的面积',
                    width:300,
                    typeAhead: true,
                    name:'reCurrentlyArea',
                    typeAhead:false,
                    editable:false
                }, {
                    xtype:'combobox',
                    id:'reCurrentlyHouse',
                    store: reCurrentlyHouseStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'目前居住/办公的房子属性',
                    width:300,
                    typeAhead: true,
                    name:'reCurrentlyHouse',
                    typeAhead:false,
                    editable:false,
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            var record = reCurrentlyHouseStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('reCurrentlyHouse').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('reCurrentlyHouse').setValue(parseInt(value.lastValue));
                            }

                        }
                    }
                }]
            }, {
                items: [{
                    xtype:'numberfield',
                    fieldLabel: '目前家庭住宅已按揭数',
                    width:300,
                    name: 'reResidentialMortgage',
                    id:'reResidentialMortgage',
                    maxLength:3,
                    hideTrigger:true,
                    regex:/^[1-9]\d*$/
                },{
                    xtype:'combobox',
                    id:'reCurrentlyProperty',
                    store: reCurrentlyPropertyStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'目前居住的物业类型',
                    width:300,
                    typeAhead: true,
                    name:'reCurrentlyProperty',
                    typeAhead:false,
                    editable:false,
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            var record = reCurrentlyPropertyStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('reCurrentlyProperty').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('reCurrentlyProperty').setValue(parseInt(value.lastValue));
                            }
                        }
                    }
                },{
                    xtype:'combobox',
                    id:'reCurrentlyStructure',
                    store: reCurrentlyStructureStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'目前居住的户型结构',
                    width:300,
                    typeAhead: true,
                    name:'reCurrentlyStructure',
                    typeAhead:false,
                    editable:false,
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            var record = reCurrentlyStructureStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('reCurrentlyStructure').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('reCurrentlyStructure').setValue(parseInt(value.lastValue));
                            }
                        }
                    }
                }]
            }]
        };
        var items=[row_1];
        var initConfigg = {
            title:"家庭住宅情况",
            minHeight:100,
            fieldDefaults: {
                labelAlign: 'left',
                msgTarget: 'side',
                margin: 5
            },
            items:items
        };
        Ext.apply(this,initConfigg);
        this.callParent(arguments);
    }
});
Ext.define('customer.payDeposit.add.payDepositPanel',{
    extend : 'Ext.form.Panel',
    initComponent:function(){
        var coContactTimeStoreList = [
            {"value":"1","text":"早上8:30-11:30"},
            {"value":"2","text":"下午14:30-17:30"},
            {"value":"3","text":"晚上18:30-20:30"}
        ];
        var coContactTimeStore = Ext.data.Store({
            autoDestroy: true,
            fields :["value","text"],
            data : coContactTimeStoreList
        });
        var coContactWeekendStoreList = [
            {"value":"1","text":"早上8:30-11:30"},
            {"value":"2","text":"下午14:30-17:30"},
            {"value":"3","text":"晚上18:30-20:30"}
        ];
        var coContactWeekendStore = Ext.data.Store({
            autoDestroy: true,
            fields :["value","text"],
            data : coContactWeekendStoreList
        });

        coWeekendInformationStore = new Ext.data.Store({
            singleton:true,
            autoDestroy:true,
            fields: ["id", "codeName", "delFlag"],
            proxy:{
                type:'ajax',
                url:contextPath+'/system/baseCodeValue/getCodeNameByType',
                reader:{
                    type: 'json',
                    root: 'root'  //数据
                }
            },
            autoLoad:false
        });
        var row_1={
            fieldDefaults: {
                labelAlign: 'left',
                msgTarget: 'side'
            },
            border: false,
            defaults: {
                border: false,
                xtype: 'panel',
                flex: 1,
                layout: 'anchor'
            },
            layout: 'hbox',
            items: [{
                items: [{
                    xtype:'combobox',
                    id:'coContactTime',
                    store: coContactTimeStore,
                    displayField: "text",
                    valueField: "value",
                    fieldLabel:'工作日联系时间',
                    width:300,
                    typeAhead: true,
                    name:'coContactTime',
                    typeAhead:false,
                    editable:false
                }, {
                    xtype:'combobox',
                    id:'coInformationDays',
                    store: coWeekendInformationStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'工作日联系方式',
                    width:300,
                    typeAhead: true,
                    name:'coInformationDays',
                    editable:false,
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            var record = coWeekendInformationStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('coInformationDays').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('coInformationDays').setValue(parseInt(value.lastValue));
                            }

                        }
                    }
                }, {
                    xtype:'textarea',
                    fieldLabel: '备注',
                    width:300,
                    name:'remark',
                    id:'remark'
                }]
            }, {
                items: [{
                    xtype:'combobox',
                    id:'coContactWeekend',
                    store: coContactWeekendStore,
                    displayField: "text",
                    valueField: "value",
                    fieldLabel:'周末联系时间',
                    width:300,
                    typeAhead: true,
                    name:'coContactWeekend',
                    typeAhead:false,
                    editable:false
                },{
                    xtype:'combobox',
                    id:'coWeekendInformation',
                    store: coWeekendInformationStore,
                    displayField: "codeName",
                    valueField: "id",
                    fieldLabel:'周末联系方式',
                    width:300,
                    typeAhead: true,
                    name:'coWeekendInformation',
                    editable:false,
                    queryMode:'local',
                    listeners: {
                        change: function(value){
                            console.log("周末联系方式: " + value);
                            var record = coWeekendInformationStore.find("id", value.lastValue);
                            if(record == -1){
                                Ext.getCmp('coWeekendInformation').setValue("");
                            }else{
                                //手动改变获取到的值类型
                                Ext.getCmp('coWeekendInformation').setValue(parseInt(value.lastValue));
                            }

                        }
                    }
                }]
            }]
        };
        var items=[row_1];
        var initConfigg = {
            title:"联系信息",
            minHeight:100,
            fieldDefaults: {
                labelAlign: 'left',
                msgTarget: 'side',
                margin: 5
            },
            items:items
        };
        Ext.apply(this,initConfigg);
        this.callParent(arguments);
    }
});

function getValue(str){
    var strArray=new Array();
    if(str && str.indexOf(",")!=-1){
        var sqArr = str.split(",");
        for(var x=0;x<sqArr.length;x++){
            var shequ = parseInt(sqArr[x]);
            strArray.push(shequ);
        }
    }else{
        if(null!=str && str!=""){
            strArray.push(parseInt(str));
        }
    }
    return strArray;
}

Ext.define('customer.payDeposit.addPanel',{
    extend : 'Ext.form.Panel',
    initComponent:function(){
        var estatePanel= Ext.create("customer.payDeposit.add.estatePanel");
        var customerPanel= Ext.create("customer.payDeposit.add.customerPanel");
        var payDepositPanel= Ext.create("customer.payDeposit.add.payDepositPanel");
        var jiatingPanel= Ext.create("customer.payDeposit.add.jiatingPanel");
        var zhuzhaiPanel= Ext.create("customer.payDeposit.add.zhuzhaiPanel");
        var firstjiePanel= Ext.create("customer.payDeposit.add.firstjiePanel");
        var membergePanel= Ext.create("customer.payDeposit.add.membergePanel");
        estatePanel.getForm().load({
            url:contextPath+'/customer/customer/findCustomerInfoCN',
            params:{'customerId':customerId},
            success:function(form, action){
                objData = action.result.data;
                //设置第二个form值
                customerPanel.getForm().setValues(action.result.data);
                //设置第三个form值
                payDepositPanel.getForm().setValues(action.result.data);
                //设置第四个form值
                jiatingPanel.getForm().setValues(action.result.data);
                zhuzhaiPanel.getForm().setValues(action.result.data);
                firstjiePanel.getForm().setValues(action.result.data);
                membergePanel.getForm().setValues(action.result.data);

                var obj = action.result.data;
                //设置第二个form值的关注重点
                var rqFocusId=obj.rqFocusId;
                var rqLifeSupport=obj.rqLifeSupport;
                var rqServicesId=obj.rqServicesId;
                var peActivityType=obj.peActivityType;
                var richangxinxi=obj.richangxinxi;
                var peHobbyId=obj.peHobbyId;
                var rqFocusIdArray=new Array();
                customerPanel.getForm().findField("rqLifeSupport").setValue(getValue(rqLifeSupport));
                customerPanel.getForm().findField("rqServicesId").setValue(getValue(rqServicesId));
                membergePanel.getForm().findField("peActivityType").setValue(getValue(peActivityType));
                membergePanel.getForm().findField("richangxinxi").setValue(getValue(richangxinxi));
                membergePanel.getForm().findField("peHobbyId").setValue(getValue(peHobbyId));
                if(rqFocusId && rqFocusId.indexOf(",")!=-1){
                    var sqArr = rqFocusId.split(",");
                    for(var x=0;x<sqArr.length;x++){
                        var shequ = parseInt(sqArr[x]);
                        rqFocusIdArray.push(shequ);
                    }
                    customerPanel.getForm().findField("rqFocusId").setValue(rqFocusIdArray);
                }else{
                    if(null!=rqFocusId && rqFocusId!=""){
                        rqFocusIdArray.push(parseInt(rqFocusId))
                        customerPanel.getForm().findField("rqFocusId").setValue(rqFocusIdArray);
                    }
                }
                if(obj.ftContactTime!=""&&obj.ftContactTime!=null){
                    console.log("周末联系方式2222: " + Ext.Date.format(new Date(obj.ftContactTime),'Y-m-d H:i'));
                    firstjiePanel.getForm().findField("ftContactTimes").setValue(Ext.Date.format(new Date(obj.ftContactTime),'Y-m-d H:i'));
                }else{
                    firstjiePanel.getForm().findField("ftContactTimes").setValue(Ext.Date.format(new Date(),'Y-m-d H:i'));
                }


                var peProvinceId = obj.peWorkaroundProvinceId;
                var peCityId = obj.peWorkaroundCityId;
                var provinceId = obj.peResidenceProvinceId;
                var cityId = obj.peResidenceCityId;
                peWorkaroundCityIdStore.load({
                    params:{
                        'id':peProvinceId
                    }
                });
                peWorkaroundAreaIdStore.load({
                    params:{
                        'id':peCityId
                    }
                });
                peResidenceCityIdStore.load({
                    params:{
                        'id':provinceId
                    }
                });
                peResidenceAreaIdStore.load({
                    params:{
                        'id':cityId
                    }
                });

                //为全员营销或者外部推荐时，展示推荐人信息
                if(obj.informedWay=="12"||obj.informedWay=="13"){
                    Ext.getCmp('recommendedCategory').show();
                    Ext.getCmp('recommendedName').show();
                    Ext.getCmp('recommendedMobile').show();
                    Ext.getCmp('recommendedUnit').show();
                }else{
                    Ext.getCmp('recommendedCategory').hide();
                    Ext.getCmp('recommendedName').hide();
                    Ext.getCmp('recommendedMobile').hide();
                    Ext.getCmp('recommendedUnit').hide();
                }

                //联系电话,获知途径是否可编辑
                Ext.getCmp('customerPhone').setEditable(obj.canEditMobile);
                Ext.getCmp('informedWay').enable();
                if(!obj.canEditInformedWay){
                    Ext.getCmp('informedWay').disable();
                }
                Ext.getCmp('ftContactWay').enable();
                if(!obj.canEditFtContactWay){
                    Ext.getCmp('ftContactWay').disable();
                }
            },
            failure: function(form, action) {
                Ext.Msg.alert("加载失败", action.result.errorMessage);
            }

        });

        var defaultConfigg = {
            buttonAlign:'center',
            id:'allFormPanel',
            defaults: {
                split: true,    //有分割线
                collapsible: true,  //可以折叠
            },
            renderTo:Ext.getBody(),
            items:[estatePanel,firstjiePanel,customerPanel,membergePanel,jiatingPanel,zhuzhaiPanel,payDepositPanel],
            buttons:[
                {xtype: "button",text: "保存",iconCls:'icon-save',handler: function(){

                        var flag = true;
                        var customerPhone = Ext.getCmp('customerPhone').getValue();
                        if(customerPhone){
                            //在验证手机号码是否正确
                            Ext.Ajax.request({
                                url: contextPath+'/common/mobile/verifyingMobile',
                                params: {
                                    mobile: customerPhone,
                                },
                                method: 'POST',
                                async: false,
                                success: function(response){
                                    var text = Ext.decode(response.responseText);
                                    if(text.result=="1"){
                                        if(text.flag != "1"){
                                            Ext.MessageBox.alert('提示', '请输入正确的手机号码');
                                            flag=false;
                                            return;
                                        }
                                    }
                                }
                            });
                            //判断手机号是否存在
                            var projectId = Ext.getCmp('cbstore').getValue();
                            var customerId = Ext.getCmp('customerId').getValue();
                            console.log("customerId = " + customerId);
                            Ext.Ajax.request({
                                url: contextPath+'/customer/customer/customerPhone',
                                params: {
                                    phone: customerPhone,
                                    projectId:projectId,
                                    id:customerId
                                },
                                method: 'POST',
                                success: function(response){
                                    var text = Ext.decode(response.responseText);
                                    if(text.res=="1"){
                                        Ext.MessageBox.alert('提示', '该手机号码已存在!');
                                        flag=false;
                                        return;
                                    }else if(text.res=="10000"){
                                        Ext.MessageBox.alert("系统提示","系统异常!");
                                        flag=false;
                                        return;
                                    }else{
                                    }
                                }
                            });
                            var peMobile = Ext.getCmp('peMobile').getValue();
                            if(customerPhone == peMobile){
                                Ext.MessageBox.alert('提示', '联系号码与手机号码重复');
                                flag=false;
                                return;
                            }
                        }
                        var form = Ext.getCmp("allFormPanel").getForm();
                        if(form.isValid()){
                            var jsonArray=[];
                            var records=gridStore.getCount();
//					     		if(records<=0){
//					     			Ext.Msg.alert('提示', '家庭成员不足,无法新增客户!');
//					     			flag=false;
//					     		}
                            for(var i=0;i<records;i++){

                                var record = gridStore.getAt(i).data;
                                var mobile = record.mobile;
                                if(mobile){
                                    //在验证手机号码是否正确
                                    Ext.Ajax.request({
                                        url: contextPath+'/common/mobile/verifyingMobile',
                                        params: {
                                            mobile: mobile,
                                        },
                                        method: 'POST',
                                        async: false,
                                        success: function(response){
                                            var text = Ext.decode(response.responseText);
                                            if(text.result=="1"){
                                                if(text.flag != "1"){
                                                    Ext.MessageBox.alert('提示', '家庭成员手机号错误!!!');
                                                    flag=false;
                                                    return;
                                                }
                                            }
                                        }
                                    });
                                }

                                jsonArray.push(Ext.JSON.encode(gridStore.getAt(i).data));
                            }
                            var resultJson=Ext.JSON.encode(jsonArray);


                            var jsonArray2=[];
                            var records2=gridStore2.getCount();
//					     		if(records2<=0){
//					     			Ext.Msg.alert('提示', '关注户型不足,无法新增客户!');
//					     			flag=false;
//					     		}
                            for(var i=0;i<records2;i++){
                                jsonArray2.push(Ext.JSON.encode(gridStore2.getAt(i).data));
                            }
                            var resultJson2=Ext.JSON.encode(jsonArray2);


                            var jsonArray3=[];
                            var records3=gridStore3.getCount();
                            var jsonArray4=[];
                            var records4=gridStore4.getCount();
                            var customerStar=Ext.getCmp("customerStar").getValue();
                            if(customerStar=="1" || customerStar=="2"){
                                if(records3<=0){
                                    Ext.Msg.alert('提示', '请选择意向组团!');
                                    return;
                                }
                                if(records4<=0){
                                    Ext.Msg.alert('提示', '请选择意向房源!');
                                    return;
                                }
                            }


                            for(var i=0;i<records3;i++){
                                jsonArray3.push(Ext.JSON.encode(gridStore3.getAt(i).data));
                            }
                            var resultJson3=Ext.JSON.encode(jsonArray3);
                            for(var i=0;i<records4;i++){
                                var newObj = {};
                                newObj.roomId=gridStore4.getAt(i).data.roomId;
                                jsonArray4.push(Ext.JSON.encode(newObj));
                            }
                            var resultJson4=Ext.JSON.encode(jsonArray4);

                            if(flag){
                                Ext.Ajax.request({
                                    url: contextPath+'/customer/customer/update?gridJson='+resultJson+'&gridJson2='+resultJson2+'&gridJson3='+resultJson3+'&gridJson4='+resultJson4,
                                    params:form.getValues(),
                                    callback: function (options, success, response) {
                                        if (success) {
                                            var obj = JSON.parse(response.responseText);
                                            if(obj.res=="1"){
                                                Ext.MessageBox.alert("系统提示","保存成功");
                                                setTimeout(function(){
                                                    var val = Ext.getCmp('cbstore').getValue();
                                                    //location.href=contextPath+'/customer/customer/index';
                                                    location.href=contextPath + "/customer/customer/toDetail?customerId="+obj.obj+"&resourcesCode=menu_0006_0001&projectId="+val;
                                                }, 2000) ;
                                            }else{
                                                Ext.MessageBox.alert("系统提示",obj.resMsg);
                                            }
                                        }else{
                                            Ext.MessageBox.alert("系统提示","系统异常!");
                                        }
                                    }

                                });
                            }

                        }

                    }},
//				         {xtype: "button",text: "提交审核",iconCls:'icon-save',handler: function(){
//
//				         }},
                {xtype: "button",text: "返回",iconCls:'icon-save',handler: function(){
                        location.href=contextPath+'/customer/customer/index?menu=menu_0006_0001';
                    }}
            ]
        };
        Ext.apply(this,defaultConfigg);
        this.callParent(arguments);
    }
});

function comoboxReset(value, focusStore, focusId){
    value = Ext.getCmp(focusId).getValue();
    //多选框复制出错,暂时注释以保证功能有效
    var removeArr = new Array();
    var focusArr = value;
    //获取现有多选记录,并判断下拉值是否存在
    for(var ii=0; ii<focusArr.length; ii++){
        var record = focusStore.find("id", focusArr[ii]);
        //不存在,将不存在的数组下标值存入要移除的数组
        if(record == -1){
            removeArr.push(ii);
        }
    }
    //移除原关注的不存在下标
    for(var ii=0; ii<removeArr.length; ii++){
        focusArr.splice(removeArr[ii],1);
    }
    if(removeArr.length == 0){
        Ext.getCmp(focusId).setValue(value, false);
    }else{
        Ext.getCmp(focusId).setValue([], false);
        //将不存在的数据移除后,set新的值不生效,只显示对应的数字.
        //此处有待优化,暂时先设置为空
        //拼接新的参数值
        var newFocusArr = new Array();
        for(var ii=0; ii<focusArr.length; ii++){
            newFocusArr.push(focusArr[ii]);
        }
        //重新设置值
        if(newFocusArr.length == 0){
            Ext.getCmp(focusId).setValue([], false);
        }else{
            //手动改变获取到的值类型
            Ext.getCmp(focusId).setValue(newFocusArr, false);
        }
    }
}
function projectReloadStore(storeId, focusStore){
    var value = Ext.getCmp(storeId).getValue();
    var record = focusStore.find("id", value)
    if(record == -1){
        Ext.getCmp(storeId).setValue("");
    }else{
        //手动改变获取到的值类型
        Ext.getCmp(storeId).setValue(parseInt(value));
    }
}

